<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0,user-scalable=no,minimal-ui">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../img/asset-favico.ico">
    <title>健康干预</title>

    <link rel="stylesheet" href="../css/page-health-intervention.css" />
</head>

<body data-spy="scroll" data-target="#myNavbar" data-offset="150">
    <div class="app" id="hhh">
        <!-- 页面头部 -->
        <div class="top-header">
            <span class="f-left"><i class="icon-back" ></i><a href="health-index.html" style="color: white">返回</a></span>
            <span class="center">千锋健康</span>
            <span class="f-right"><i class="icon-more"></i></span>
        </div>
        <!-- 页面内容 -->
        <div class="contentBox">
            <div class="tab-wrapper">
                <ul class="tab-menu">
                    <li class="active">膳食方案</li>
                    <li>运动方案</li>
                    <li>干预计划</li>
                </ul>
                <div class="tab-content">
                    <div class="item">
                        <div class="intro-img">
                            <img src="../img/widget-program01.png" width="100%" />
                        </div>
                        <div class="table-title">
                            <span>餐次</span>
                            <span>推荐食物</span>
                            <span>份量</span>
                            <span>摄入量</span>
                        </div>
                        <table class="table" border="0" cellspacing="0" cellpadding="0">
                            <tbody>
                                <tr v-for="(a,b) in pro">
                                    <td>{{a.meal}}</td>
                                    <td>{{a.food}}</td>
                                    <td>{{a.intake}}g</td>
                                    <td>{{a.ingest}}k</td>
                                </tr>
<!--                                <tr>-->
<!--                                    <td>{{pro[1].meal}}</td>-->
<!--                                    <td>{{pro[1].food}}</td>-->
<!--                                    <td>{{pro[1].intake}}g</td>-->
<!--                                    <td>{{pro[1].ingest}}k</td>-->
<!--                                </tr>-->
<!--                                <tr>-->
<!--                                    <td>{{pro[2].meal}}</td>-->
<!--                                    <td>{{pro[2].food}}</td>-->
<!--                                    <td>{{pro[2].intake}}g</td>-->
<!--                                    <td>{{pro[2].ingest}}k</td>-->
<!--                                </tr>-->
<!--                                <tr>-->
<!--                                    <td>{{pro[3].meal}}</td>-->
<!--                                    <td>{{pro[3].food}}</td>-->
<!--                                    <td>{{pro[3].intake}}g</td>-->
<!--                                    <td>{{pro[3].ingest}}k</td>-->
<!--                                </tr>-->
                            </tbody>
                        </table>

                    </div>
                    <div class="item">
                        <div class="table-title">
                            <span>运动名称</span>
                            <span>运动时长</span>
                            <span>运动周期</span>
                            <span>消耗量</span>
                        </div>
                        <table class="table" border="0" cellspacing="0" cellpadding="0">
                            <tbody>
                                <tr v-for="(c,d) in pro">
                                    <td>{{c.sport}}</td>
                                    <td>{{c.time}}min</td>
                                    <td>{{c.cycle}}</td>
                                    <td>{{c.consume}}kal</td>
                                </tr>

                            </tbody>
                        </table>
                    </div>
                    <div class="item">
                        <div class="table-title">
                            <span>干预时间</span>
                            <span>干预形式</span>
                            <span>主要内容</span>
                        </div>
                        <table class="table" border="0" cellspacing="0" cellpadding="0">
                            <tbody>
                                <tr v-for="(e,f) in pro">
                                    <td>{{e.dining}}</td>
                                    <td>{{e.mode}}</td>
                                    <td>{{e.content}}</td>
                                </tr>
<!--                                <tr>-->
<!--                                    <td>{{pro[1].dining}}</td>-->
<!--                                    <td>{{pro[1].mode}}</td>-->
<!--                                    <td>{{pro[1].content}}</td>-->
<!--                                </tr>-->
<!--                                <tr>-->
<!--                                    <td>{{pro[2].dining}}</td>-->
<!--                                    <td>{{pro[2].mode}}</td>-->
<!--                                    <td>{{pro[2].content}}</td>-->
<!--                                </tr>-->
<!--                                <tr>-->
<!--                                    <td>{{pro[3].dining}}</td>-->
<!--                                    <td>{{pro[3].mode}}</td>-->
<!--                                    <td>{{pro[3].content}}</td>-->
<!--                                </tr>-->
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- 页面 css js -->

    <script src="../plugins/jquery/dist/jquery.min.js"></script>
    <script src="../js/page-health-intervention.js"></script>
</body>
<script src="../js/vue.js"></script>
<script src="../js/axios-0.18.0.js"></script>
<script>
    new Vue({
        el:"#hhh",
        data:{
            // 存放用户信息
            pro : []
        },
        mounted() {
            this.findUser();
        },
        methods:{
            findUser() {
                axios.defaults.withCredentials = true;
                axios({
                    url: "http://localhost:81/second",
                    method: "post",
                    headers: {
                        "Authorization": "Bearer " + localStorage.getItem("token")
                    }
                }).then(resp=>{
                    this.hasToken(resp)
                    let result = resp.data;
                    if (result.code === 1000) {
                        this.pro = result.data;

                    }
                })
            },
            hasToken(resp) {
                let refreshToken = resp.headers.refresh_token;
                if (refreshToken!=null&&refreshToken.length!=0){
                    localStorage.setItem("token",refreshToken)
                }
                let res = resp.data;
                if (res.code == 2000){
                    //没有登录  -- 跳转到登录页面
                    location.href = "./health-login.html"
                }else if(res.code == 3000){
                    //没有权限
                    alert(res.msg)
                }else if(res.code == 1000){
                    //访问数据成功
                    this.msg = res;
                }
            }
        }
    })
</script>